'use strict';

const Controller = require('egg').Controller;

class UserController extends Controller {
  async login() {
    // 接收post参数
    // const { ctx } = this;
    // console.log('方式二：params', ctx.params);
    // ctx.body = `id==${ctx.params.id}`;
    // 接收get参数
    const { ctx } = this;
    const params = {
      userName: ctx.request.body.userName,
      password: ctx.request.body.password,
    };
    // console.log('方式一：query', ctx.query);
    ctx.body = {
      msg: '登录成功',
      code: 200,
      data: params,
    };
  }
  async list() {
    const { ctx } = this;
    const result = await this.ctx.service.user.login();
    ctx.body = result;
  }
}

module.exports = UserController;
